package com.ophiux.common.data.headers;

import com.alibaba.ttl.TransmittableThreadLocal;
import lombok.experimental.UtilityClass;

/**
 * @desc: Headers工具类
 * @author: hhl
 * @date：2022/8/18 13:43
 */
@UtilityClass
public class HeaderParamsContextHolder {

    private final TransmittableThreadLocal<HeaderParams> THREAD_LOCAL_ACCESS_TOKEN = new TransmittableThreadLocal<>();

    /**
     * 设置
     *
     * @param headerParams
     */
    public void setHeaderParams(HeaderParams headerParams) {
        THREAD_LOCAL_ACCESS_TOKEN.set(headerParams);
    }

    /**
     * 获取
     *
     * @return
     */
    public HeaderParams getHeaderParams() {
        return THREAD_LOCAL_ACCESS_TOKEN.get();
    }

    /**
     * 清除
     */
    public void clear() {
        THREAD_LOCAL_ACCESS_TOKEN.remove();
    }

}
